package ua.epam.java_bravo.manager;

import java.util.ResourceBundle;

/**
 * Utility class for getting configuration
 * from 'properties' files
 *
 * Created by IntelliJ IDEA.
 * User: Linderhof
 * Date: 15.12.2010
 * Time: 13:26:19
 */
public class ConfigurationManager {
    private static ConfigurationManager instance;
    private ResourceBundle resourceBundle;

    //getts configuration from config.properties
    private static final String BUNDLE_NAME = "config";

    public static final String DATABASE_DRIVER_NAME =
        "DATABASE_DRIVER_NAME";
    public static final String DATABASE_URL =
        "DATABASE_URL";
    public static final String ERROR_PAGE_PATH =
        "ERROR_PAGE_PATH";
    public static final String LOGIN_PAGE_PATH =
        "LOGIN_PAGE_PATH";
    public static final String MAIN_PAGE_PATH =
        "MAIN_PAGE_PATH";
    public static final String root_password =
        "root_password";
    public static final String ADDR_VIEW_PATH =
        "ADDR_VIEW_PATH";
    public static final String ADDR_FORM_PATH =
        "ADDR_FORM_PATH";


    //Singleton
    public static ConfigurationManager getInstance() {
        if (instance == null) {
            instance = new ConfigurationManager();
            instance.resourceBundle =
                ResourceBundle.getBundle(BUNDLE_NAME);
        }
        return instance;
    }

    //Gets property by name
    public String getProperty(String key) {
        return (String)resourceBundle.getObject(key);
    }
    
}
